package com.andyage.admin.action;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.andyage.admin.service.IAditemService;
import com.andyage.util.GetUUID;
import com.andyage.util.TypeTransfor;
import com.andyage.admin.bean.AditemBean;

@Controller
@RequestMapping("/admin")
public class AditemAction {
	@Resource
	private IAditemService iaditemService;
	@RequestMapping("/queryAdItemByCondition")
	public void queryAdItemByCondition(HttpServletRequest request, HttpServletResponse response, AditemBean aditem) {
		try {
			//String itemProjectId=request.getParameter("itemProjectId");
			//aditem.setItemProjectId(itemProjectId);
			iaditemService.queryAdItemByCondition(request, response, aditem);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	@RequestMapping("/updateAditem")
	public void updateAditem(HttpServletRequest request, HttpServletResponse response, AditemBean aditem) {
		try {
			String itemaddress=request.getParameter("itemaddress");
			String AwardStatus= request.getParameter("AwardStatus");
			if(itemaddress!=null &&!"".equals(itemaddress)){
				if("是".equals(itemaddress)||"1".equals(itemaddress)){
					aditem.setItemUseReceiveraddress(true);
				}else{
					aditem.setItemUseReceiveraddress(false);
				}
			}
			if(AwardStatus!=null&&!"".equals(AwardStatus)){
				if("不参与".equals(AwardStatus)||"1".equals(AwardStatus)){
					aditem.setItemAwardStatus(1);
				}else{
					aditem.setItemAwardStatus(2);
				}
			}
			iaditemService.updateAditem(request, response, aditem);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	@RequestMapping("/addAditem")
	public void addAditem(HttpServletRequest request, HttpServletResponse response, AditemBean aditem) {
		try {
			aditem.setItemId(GetUUID.get());
			iaditemService.addAditem(request, response, aditem);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	@RequestMapping("/deleteAditem")
	public void deleteAditem(HttpServletRequest request, HttpServletResponse response) {
		try {
			iaditemService.deleteAditem(request, response);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
